const companyIdName = 'bimCom'
const projectIdName = 'bimPro'

const bimInfo = {
    namespaced: true,
    state: {
        branchCompanyId: '',
        projectId: '',
    },
    getters: {
        GET_COMPANYID(state) {
            return state.branchCompanyId || sessionStorage.getItem(companyIdName)
        },
        GET_PROJECTID(state) {
            return state.projectId || sessionStorage.getItem(projectIdName)
        },
    },
    mutations: {
        SET_COMPANYID(state, branchCompanyId) {
            state.branchCompanyId = branchCompanyId
            sessionStorage.setItem(companyIdName, branchCompanyId)
        },
        SET_PROJECTID(state, projectId) {
            state.projectId = projectId
            sessionStorage.setItem(projectIdName, projectId)
        },
        REMOVE_COMP_PRO(state) {
            state.branchCompanyId = ''
            state.projectId = ''
            sessionStorage.removeItem(companyIdName)
            sessionStorage.removeItem(projectIdName)
            sessionStorage.removeItem('mainModel') // 清除主模型缓存
        }
    }
}

export default bimInfo